<?php

namespace xinqdian\modules\guestbook\controller;

use App\Controller as Controller;
use App\Helper as Helper;
use App\Cache\Exception as Cache_Exception;
use xinqdian\modules\guestbook\model as Model;
use xinqdian\modules\guestbook\config as Config;
use xinqdian\modules\guestbook\widget\Comment as Comment;

class index extends Controller
{
    public function __construct()
    {
        parent::init();
    }

    public function defaultAction()
    {
        echo __METHOD__;
        echo "<hr />";

        try
        {
            $db = new Helper\Sqlite(__DIR__ . '/mysqlite3.db');
            //$db->exec('create table test(id int, name string)');
            //$db->exec('insert into test(id,name)values(1, \'sanbao\')');
            $result = $db->prepare("select * from test")->execute()->getResult()->numColumns();//fetchArray();

            var_dump($db, $result);
        }
        catch(\Exception $e)
        {
            echo $e->getMessage();
        }
        exit;
    }

    public function indexAction()
    {

        echo __METHOD__;
        $widget = new Comment\Widget();
        $widget->render();


        /**
            注入View:
                $view->addWidget($commentWidget);

            调用Widget:
                $view->getWidget('comment')->render(); 或 $view->getWidget('comment')->renderDelay();
        */
    }
}